package client.comm.baoding.ui.vm

import android.app.Application
import androidx.lifecycle.MutableLiveData
import client.comm.commlib.network.data.JsonResult
import client.comm.baoding.api.bean.Zcjl
import client.comm.baoding.ui.viewmodel.MiddleVm


class SfjlViewModel(app: Application) : MiddleVm(app) {
    val isShowing = MutableLiveData<Boolean>(false)

    val isOneLoading = MutableLiveData<Boolean>(false)
    val isTwoLoading = MutableLiveData<Boolean>(false)
    val pageOne = MutableLiveData<Int>(0)
    val pageTwo = MutableLiveData<Int>(0)
    val callOne = MutableLiveData<JsonResult<Zcjl>>()
    val callTwo = MutableLiveData<JsonResult<Zcjl>>()

    fun holdOne() {
        if (isOneLoading.value!!)
            return
        hold({
            server.zcjl(pageOne.value!!, 10)
        }, {
            isOneLoading.value = true
            pageOne.value = pageOne.value!! + 1
        }, {
            callOne.value = it
        }, complete = {
            isOneLoading.value = false
        })
    }

    fun holdTwo() {
        if (isTwoLoading.value!!)
            return
        hold({
            server.zcjl(pageTwo.value!!, 11)
        }, {
            isTwoLoading.value = true
            pageTwo.value = pageTwo.value!! + 1
        }, {
            callTwo.value = it
        }, complete = {
            isTwoLoading.value = false
        })
    }

}